#include "casual_includes.h"
#include "acquisition.h"
#include "execution.h"
#include "interboursier.h"
#include "terminal.h"
#include "../libbourse/alea.h"
#include "../libcomm/communication.h"

int main(void){
	printf("Lancement du programme\n");
	init_log("bourse.log");
	char valeur[5];	sprintf(valeur, "%d", alea(1, 50));
	module *exect1=init_module("Execution 01",exec,1);
	module *ack1=init_module("Acquisition 01",ack,1);
	module *term1=init_module("Terminal 01",term,1);
	module *term2=init_module("Terminal 02",term,1);
	module *term3=init_module("Terminal 03",term,1);
	module *term4=init_module("Terminal 04",term,1);
	module *inter=init_module("Interboursier",interb,0);

	launch_interboursier(inter,1200); sleep(3); // on attend 3sec avant de lancer Acquisition
	launch_acquisition(ack1,1201); sleep(1);
	launch_execution(exect1,1202); sleep(1);
	launch_terminal(term1,1201); sleep(1);
	launch_terminal(term2,1201); sleep(1);
	launch_terminal(term3,1201); sleep(1);
	launch_terminal(term4,1201); sleep(1);
	sleep(100); // oblige l'utilisateur à faire ctrl+c pour terminer le programme sinon erreur de bind ... :s
	//kill(getpid(),SIGKILL);
	printf("fin.\n");
	return 0;
}
